<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>轮播图</title>
    <link rel="stylesheet" href="/Public/layui/css/layui.css"  media="all">
    <style>
        .layui-input-block input{
            width:200px;
        }

    </style>
</head>
<body>

<form class="layui-form" action="" style = "margin-top:30px;">
    <div class="layui-form-item">
        <label class="layui-form-label">标题:</label>
        <div class="layui-input-block">
            <input id="title" type="text" name="title" class="layui-input" value="<?php echo ($list["title"]); ?>">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">顺序:</label>
        <div class="layui-input-block">
            <input id="order" type="number" name="order" class="layui-input" value="<?php echo ($list["order"]); ?>">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">状态:</label>
        <div class="layui-input-block">
            <!--<input id="order" type="number" name="order" class="layui-input" value="<?php echo ($list["order"]); ?>">-->
            <input type="radio" name="status" value="1" title="启用"<?php if($list["status"] == 1): ?>checked<?php endif; ?>>
            <input type="radio" name="status" value="0" title="禁用" <?php if($list["status"] == 0): ?>checked<?php endif; ?>>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">类型:</label>
        <div class="layui-input-block">
            <!--<input id="order" type="number" name="order" class="layui-input" value="<?php echo ($list["order"]); ?>">-->
            <input type="radio" name="type" value="1" title="社区"<?php if($list["type"] == 1): ?>checked<?php endif; ?>>
            <input type="radio" name="type" value="2" title="闲置" <?php if($list["type"] == 2): ?>checked<?php endif; ?>>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">备注:</label>
        <div class="layui-input-block">
            <textarea id ="remark" name="remark" class="layui-input" style = "width:200px;height:100px;"><?php echo ($list["remark"]); ?></textarea>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">图片:</label>
        <div class="layui-input-block">
            <button type="button" class="layui-btn" id="img">
                <i class="layui-icon">&#xe67c;</i>上传图片
            </button>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label"></label>
        <div class="layui-input-block" id="imglist">
            <img src = "<?php echo ($list["img_file"]); ?>" style = 'width:150px;height:250px;'/>
            <input type = 'hidden' id = 'img_file' name = 'img_file' value = '<?php echo ($list["img_file"]); ?>'/>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit="" lay-filter="formDemo">立即提交</button>
        </div>
    </div>
    <input id="id" name = "id" type="hidden" value="<?php echo ($list["id"]); ?>">
</form>
<!-- 配置文件 -->
<script type="text/javascript" src="/Public/ueditor/ueditor.config.js"></script>
<!-- 编辑器源码文件 -->
<script type="text/javascript" src="/Public/ueditor/ueditor.all.js"></script>
<!-- 实例化编辑器 -->
<script type="text/javascript">
    // var editor = UE.getEditor('container');
</script>
<script src="/Public/layui/layui.js" charset="utf-8"></script>
<script src="/Public/js/jquery-1.11.1.min.js" charset="utf-8"></script>
<script type="text/javascript">
    layui.use(['element','laypage','laytpl','layer','upload', 'form'], function(){
        var upload = layui.upload,layer=layui.layer,form = layui.form,$=layui.jquery;
        //执行实例
        var uploadInst = upload.render({
            elem: '#img' //绑定元素
            ,url: '<?php echo U("uploadFile");?>' //上传接口
            ,multiple:false
            ,done: function(res){
                //上传完毕回调
                // layer.alert(res.url)
                $("#imglist").empty();
                $("#imglist").append("<img src = "+res.url+" style = 'width:150px;height:250px;'/>");
                $("#imglist").append("<input type = 'hidden' id = 'img_file' name = 'img_file' value = '"+res.url+"'/>");
            }
            ,error: function(){
                //请求异常回调
                layer.alert(res)
            }
        });
        form.on('submit(formDemo)', function(data){
            // layer.msg(JSON.stringify(data.field));
            if(''==data.field.order || parseInt(data.field.order)<=0){
                layer.alert('顺序大于0');
                return false;
            }
            $.post('<?php echo U("save");?>',data.field,function(e){
                // layer.alert(e);
                if(1 == e){
                    layer.alert('修改成功');
                    setTimeout(function(){
                        window.parent.location.reload();
                    },2000);
                }else{
                    layer.alert('修改失败');
                }
            })
            return false;
        });
    });
</script>
</body>
</html>